# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Michael Migliore <mcmigliore+aur@gmail.com>
# Contributor: Mathieu Wespthal <mathieu.westphal+aur@gmail.com>
pkgname=f3d
pkgver=2.2.1
pkgrel=3
pkgdesc='A fast and minimalist 3D viewer'
arch=('loong64' 'x86_64')
url="https://github.com/${pkgname}-app/${pkgname}"
license=('BSD')
depends=('vtk' 'glew' 'pugixml' 'netcdf' 'ospray' 'assimp' 'opencascade' 'alembic'
         'fmt' 'nlohmann-json' 'draco' 'libxcursor' 'verdict')
makedepends=('cmake' 'help2man' 'openmp' 'pybind11' 'ninja' 'eigen' 'utf8cpp' 'python' 'jdk-openjdk')
source=("$pkgname-$pkgver.tar.gz::https://github.com/$pkgname-app/$pkgname/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('4d3a73b0107c8db7f0556107c74087d3748232a73981f65f7c5186ac1003ec8d')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  export CXXFLAGS+=" -ffat-lto-objects"
  cmake \
    -GNinja \
    -Bbuild \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DF3D_BINDINGS_JAVA=ON \
    -DF3D_BINDINGS_PYTHON=ON \
    -DF3D_LINUX_GENERATE_MAN=ON \
    -DF3D_MODULE_RAYTRACING=ON \
    -DF3D_MODULE_EXTERNAL_RENDERING=ON \
    -DF3D_PLUGINS_STATIC_BUILD=ON \
    -DF3D_PLUGIN_BUILD_ALEMBIC=ON \
    -DF3D_PLUGIN_BUILD_ASSIMP=ON \
    -DF3D_PLUGIN_BUILD_DRACO=ON \
    -DF3D_PLUGIN_BUILD_OCCT=ON
  ninja -C build
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  DESTDIR="$pkgdir" cmake --install build
  DESTDIR="$pkgdir" cmake --install build --component mimetypes
  DESTDIR="$pkgdir" cmake --install build --component sdk
  DESTDIR="$pkgdir" cmake --install build --component configuration
  install -Dm644 LICENSE.md "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE.md
}
